package com.orangelife.mobile.parkingcard.activity;

import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.common.util.OrangePhoneUtil;
import com.curry.android.util.IntentHelper;
import com.curry.orangelife.mobile.R;
import com.orangelife.mobile.common.activity.OrangeLifeBaseActivity;
import com.orangelife.mobile.util.StringUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by yyx
 * on 2015/11/17.
 */
public class ParkingAuthenticationErrorActivity extends OrangeLifeBaseActivity {

    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.iv_title_right)
    ImageView ivTitleRight;
    @Bind(R.id.ivNoVal)
    ImageView ivNoVal;
    @Bind(R.id.btnApplyAgain)
    Button btnApplyAgain;

    private String phone = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_parking_authentication_error);

        ButterKnife.bind(this);

        initView();
        findView();
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    private void initView() {
        tvTitle.setText("身份认证");
        ivTitleRight.setVisibility(View.VISIBLE);
        ivTitleRight.setBackgroundResource(R.drawable.icon_phone);
    }

    private void findView() {
        Intent intent = getIntent();
        phone = intent.getStringExtra("phone");
        ivTitleRight.setOnClickListener(listener);
        btnApplyAgain.setOnClickListener(listener);
    }

    private View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.iv_title_right:
                    if(StringUtil.isBlank(phone)){
                        OrangePhoneUtil.callCustomerService2(ParkingAuthenticationErrorActivity.this);
                    }else{
                        OrangePhoneUtil.callCommProperty(ParkingAuthenticationErrorActivity.this,phone);
                    }
                    break;
                case R.id.btnApplyAgain:
                    IntentHelper.getInstances().getIntent(ParkingAuthenticationErrorActivity.this,ParkingAuthenticationActivity.class);
                    finish();
                    break;
            }
        }
    };
}
